package artibella.utils 
{
	/**
	 * ...
	 * @author pbordachar
	 */
	
	 public class FormsUtils
	{
		
		public function FormsUtils()
		{
			throw new Error( "FormsUtilities : bad use" );
		}
		
		///////  S T A T I C
		
		public static function validateEmail( s:String ):Boolean 
		{
            var pattern:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
            var result:Object = pattern.exec( s );
            if( result == null ) {
                return false;
            }
            return true;
        }

		public static function checkEmailCredibility( s:String ):Boolean
		{
			if ( s.indexOf( "@" ) <= 0
			  || s.indexOf( "@" ) != s.lastIndexOf( "@" )
			  || s.indexOf( "@" ) == s.length - 1 
			  || s.indexOf( "." ) == s.indexOf( "@" ) - 1
			  || s.indexOf( "." ) == s.indexOf( "@" ) + 1
	 		  || s.indexOf( "." ) == -1
			  || s.lastIndexOf( "." ) == s.length - 1 ){
				
				return false;
				
			} else {
				
				return true;
			}
		}
		
		// - - -
		
		public static function checkDateExistence( jj:int, mm:int, aaaa:int ):Boolean
		{
			var tabJoursMois:Array = new Array( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
			
			var isBisextile:Boolean = ( (aaaa%4) == 0 ) ? true : false; 
			if( isBisextile ) tabJoursMois[ 1 ] = 29;
			
			if( mm <= 12 ){
				if( jj <= tabJoursMois[ mm-1 ] ){
					return true;
				} 
			} 
			
			return false;
		}
	}
}